package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * *
 * Created by IntelliJ IDEA.
 * Author: caoLei
 * Date: 2018/10/22
 * Time: 16:55
 * *
 */
public interface BrandMapper extends Mapper<Brand>, SelectByIdListMapper<Brand, Long> {


    /**
     * 新增商品分类和品牌中间表数据
     *
     * @param cid 商品分类id
     * @param id  品牌id
     * @return
     */
    @Insert("insert into tb_category_brand(category_id,brand_id) values(#{cid},#{id})")  //预编译的方式
    public void insertCategoryBrand(@Param("cid") Long cid, @Param("id") Long id);   //多个参数的时候，需要指定参数名



    @Select("select b.* from tb_brand b INNER JOIN tb_category_brand cb ON b.id=cb.brand_id where cb.category_id=#{cid};")
    List<Brand> queryByCategoryId(Long cid);

}
